var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, o) {
    var a, r = arguments.length, i = r < 3 ? e : null === o ? o = Object.getOwnPropertyDescriptor(e, n) : o;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) i = Reflect.decorate(t, e, n, o); else for (var s = t.length - 1; 0 <= s; s--) (a = t[s]) && (i = (r < 3 ? a(i) : 3 < r ? a(e, n, i) : a(e, n)) || i);
    return 3 < r && i && Object.defineProperty(e, n, i), i;
}, r = this && this.__awaiter || function(t, i, s, c) {
    return new (s = s || Promise)(function(n, e) {
        function o(t) {
            try {
                r(c.next(t));
            } catch (t) {
                e(t);
            }
        }
        function a(t) {
            try {
                r(c.throw(t));
            } catch (t) {
                e(t);
            }
        }
        function r(t) {
            var e;
            t.done ? n(t.value) : ((e = t.value) instanceof s ? e : new s(function(t) {
                t(e);
            })).then(o, a);
        }
        r((c = c.apply(t, i || [])).next());
    });
}, s = this && this.__generator || function(n, o) {
    var a, r, i, s = {
        label: 0,
        sent: function() {
            if (1 & i[0]) throw i[1];
            return i[1];
        },
        trys: [],
        ops: []
    }, t = {
        next: e(0),
        throw: e(1),
        return: e(2)
    };
    return "function" == typeof Symbol && (t[Symbol.iterator] = function() {
        return this;
    }), t;
    function e(e) {
        return function(t) {
            return function(e) {
                if (a) throw new TypeError("Generator is already executing.");
                for (;s; ) try {
                    if (a = 1, r && (i = 2 & e[0] ? r.return : e[0] ? r.throw || ((i = r.return) && i.call(r), 
                    0) : r.next) && !(i = i.call(r, e[1])).done) return i;
                    switch (r = 0, (e = i ? [ 2 & e[0], i.value ] : e)[0]) {
                      case 0:
                      case 1:
                        i = e;
                        break;

                      case 4:
                        return s.label++, {
                            value: e[1],
                            done: !1
                        };

                      case 5:
                        s.label++, r = e[1], e = [ 0 ];
                        continue;

                      case 7:
                        e = s.ops.pop(), s.trys.pop();
                        continue;

                      default:
                        if (!(i = 0 < (i = s.trys).length && i[i.length - 1]) && (6 === e[0] || 2 === e[0])) {
                            s = 0;
                            continue;
                        }
                        if (3 === e[0] && (!i || e[1] > i[0] && e[1] < i[3])) {
                            s.label = e[1];
                            break;
                        }
                        if (6 === e[0] && s.label < i[1]) {
                            s.label = i[1], i = e;
                            break;
                        }
                        if (i && s.label < i[2]) {
                            s.label = i[2], s.ops.push(e);
                            break;
                        }
                        i[2] && s.ops.pop(), s.trys.pop();
                        continue;
                    }
                    e = o.call(n, s);
                } catch (t) {
                    e = [ 6, t ], r = 0;
                } finally {
                    a = i = 0;
                }
                if (5 & e[0]) throw e[1];
                return {
                    value: e[0] ? e[1] : void 0,
                    done: !0
                };
            }([ e, t ]);
        };
    }
};

Object.defineProperty(n, "__esModule", {
    value: !0
}), e("gameassistant3");

var c = e("Global"), l = e("GameConfig"), d = e("GameData"), u = e("DataManager"), p = e("WebManager"), h = e("FSVideoAdManager"), f = cc._decorator, g = f.ccclass, m = f.property, y = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.progress_label = null, t.progress_sprite = null, t.box = null, t.load_total = 2, 
        t.load_progress = [], t.main_scence = "game", t.startTime = 0, t;
    }
    return i(t, e), t.prototype.onLoad = function() {
        var t = cc.view.getCanvasSize();
        t.width / t.height < 1.7 ? (cc.Canvas.instance.fitWidth = !0, cc.Canvas.instance.fitHeight = !1) : (cc.Canvas.instance.fitWidth = !1, 
        cc.Canvas.instance.fitHeight = !0), cc.Canvas.instance.node.setContentSize(cc.winSize);
    }, t.prototype.start = function() {
        this.init();
    }, t.prototype.init = function() {
        return r(this, void 0, void 0, function() {
            var e, n, o, a, r = this;
            return s(this, function(t) {
                switch (t.label) {
                  case 0:
                    if (e = GA.Platform.Default, o = n = "", a = !1, c.G.platform = c.Platform.Default, 
                    c.G.platform != c.Platform.XiaoDu) return [ 3, 2 ];
                    n = "wjycj_xiaodu", o = "468A437E-9B28-45D7-80DA-10E4565BA41E", this.load_total = 4, 
                    this.load_progress.length = this.load_total;
                    try {
                        cc.director.preloadScene(this.main_scence, function(t, e, n) {
                            r.progressCallback(t, e, n, 0);
                        }, function(t) {
                            if (t) return console.error(t);
                        });
                    } catch (t) {}
                    return [ 4, GA.init({
                        debugLog: !0,
                        isPreview: !0,
                        platform: GA.Platform.Default,
                        engine: GA.EngineType.CocosCreator,
                        appId: n,
                        channelKey: "krq_wjycj",
                        uuid: o,
                        resolution: cc.winSize,
                        sharePath: "krq_wjycj=001",
                        withoutRewardVideoAd: a
                    }) ];

                  case 1:
                    return t.sent(), this.finishProgress(1), GA.getOpenId(function() {
                        r.finishProgress(r.load_total - 1), r.loginCallback(null);
                    }), [ 3, 3 ];

                  case 2:
                    "GameAssistantWeb" in window ? (e = GA.Platform.Kuaidianwan, n = "kdw_wjycj", a = !(o = "1D74EC86-4E4E-4109-8BE0-81BC5F5E9719"), 
                    c.G.platform = c.Platform.Default, window.GameAssistantWeb.gameLoadingFinished()) : "uc" in window ? (e = GA.Platform.UCMiniGame, 
                    n = "99728e0471e04c0d9dc3f7367301c237", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), 
                    c.G.platform = c.Platform.UCMiniGame) : "qq" in window ? (e = GA.Platform.QQ, n = "1110130867", 
                    a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = "a217bea8e7a1edc9003f71d647be5bf8", 
                    l.GC.bannerAdUnitIds = [ "5883fea6607b3f61905c5fb7c0ad3741" ], l.GC.interstitialAdUnitId = "5635e5e978a0c2b12d0599bc8937a297", 
                    c.G.platform = c.Platform.QQ) : "ks" in window ? (e = GA.Platform.Kwaigame, n = "ks648799821784475690", 
                    a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = "2300000582_01", 
                    l.GC.interstitialAdUnitId = "2300000582_02", c.G.platform = c.Platform.KWAIGAME) : "tt" in window ? (e = GA.Platform.ByteDance, 
                    n = "ttc141b7fc5e6bca73", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = c.G.isIOS ? "2i46skstac853ph8a5" : "dlcgllhb38c6193p49", 
                    l.GC.bannerAdUnitIds = [ "2kxqhd8tcvx743b01l" ], l.GC.interstitialAdUnitId = "9atlff9mnn717iji28", 
                    c.G.platform = c.Platform.ByteDance) : cc.sys.platform == cc.sys.OPPO_GAME ? (e = GA.Platform.OPPO, 
                    n = "30248062", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = "162740", 
                    l.GC.bannerAdUnitIds = [ "162737" ], l.GC.interstitialAdUnitId = "162738", c.G.platform = c.Platform.OPPO) : cc.sys.platform == cc.sys.VIVO_GAME ? (e = GA.Platform.Vivo, 
                    n = "100005424", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = "162740", 
                    l.GC.bannerAdUnitIds = [ "162737" ], l.GC.interstitialAdUnitId = "162738", c.G.platform = c.Platform.Vivo) : "h5api" in window ? (e = GA.Platform.M4399MiniGame, 
                    n = "100061020", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), c.G.platform = c.Platform.H4399) : cc.sys.platform == cc.sys.WECHAT_GAME && "wx" in window ? (e = GA.Platform.WeChat, 
                    n = "wx90ee3dfe98a29944", a = !(o = "94006EE4-6490-43DB-B839-D3F8749F4070"), l.GC.videoAdUnitId = "adunit-5c7c32d605aab637", 
                    l.GC.bannerAdUnitIds = [ "adunit-1fd00d2cf73286cd", "adunit-482c46218ad1f2b3" ], 
                    l.GC.interstitialAdUnitId = "adunit-17893ec0b6586801", c.G.platform = c.Platform.WECHAT) : cc.sys.os == cc.sys.OS_IOS ? (e = GA.Platform.iOS, 
                    a = !(o = "B2D4407A-1CFF-4816-AF4E-7E9EF1AD9C79"), c.G.platform = c.Platform.Default) : cc.sys.os == cc.sys.OS_ANDROID && (e = GA.Platform.Android, 
                    a = !(o = "98A05533-B178-4F50-8203-E1BCBE75A680"), c.G.platform = c.Platform.Default), 
                    GA.Info.videoTopics = [ "我就要吃鸡", "卡日曲游戏" ], GA.init({
                        debugLog: !0,
                        isPreview: !0,
                        platform: e,
                        engine: GA.EngineType.CocosCreator,
                        appId: n,
                        channelKey: "krq_wjycj",
                        uuid: o,
                        resolution: cc.winSize,
                        sharePath: "krq_wjycj=001",
                        withoutRewardVideoAd: a
                    }).then(function() {
                        var t, e;
                        c.G.launchOptions = null === (e = null === (t = GA.PA) || void 0 === t ? void 0 : t.getLaunchOptionsSync) || void 0 === e ? void 0 : e.call(t), 
                        r.load_total += 1, r.load_progress.length = r.load_total, GA.isPlatform(GA.Platform.M4399MiniGame) ? (GA.PA.addUnsupportMethods(GA.Platform.M4399MiniGame, [ "createRewardedVideoAd", "showToast", "showModal", "setClipboardData", "vibrateShort" ]), 
                        GA.getOpenId(function() {
                            Promise.all([ new Promise(function(t) {
                                cc.resources.loadDir("audio", cc.AudioClip, function(t, e, n) {
                                    r.progressCallback(t, e, n, r.load_total - 1);
                                }, function() {
                                    t();
                                });
                            }) ]).then(function() {
                                r.loginCallback(null);
                            });
                            try {
                                cc.director.preloadScene(r.main_scence, function(t, e, n) {
                                    r.progressCallback(t, e, n, 0);
                                }, function(t) {
                                    if (t) return console.error(t);
                                });
                            } catch (t) {}
                        }, !1, !0)) : GA.getOpenId(function() {
                            r.enterCallback();
                        }, !1, !0);
                        try {
                            cc.director.preloadScene(r.main_scence, function(t, e, n) {
                                r.progressCallback(t, e, n, 0);
                            }, function(t) {
                                if (t) return console.error(t);
                            });
                        } catch (t) {}
                    }), t.label = 3;

                  case 3:
                    return [ 2 ];
                }
            });
        });
    }, t.prototype.enterCallback = function(t, e) {
        var n = this;
        void 0 === t && (t = ""), void 0 === e && (e = ""), this.finishProgress(this.load_total - 1), 
        p.default.getInstance().reqLogin({
            avatarUrl: t,
            nickname: e,
            success: function(t) {
                try {
                    GA.AdTracking.init(), GA.AdTracking.reportKeyAction(GA.AdTracking.Action.Active);
                } catch (t) {}
                n.loginCallback(t);
            }
        });
    }, t.prototype.loginCallback = function(t) {
        var n = this;
        1 < this.load_total && this.finishProgress(this.load_total - 2), u.default.getInstance().getData(t && t.data && t.data.data && t.data.data.data ? JSON.parse(t.data.data.data) : {}).then(function(e) {
            p.default.getInstance().reqConfig({
                success: function(t) {
                    console.log("reqConfig", t), t.data.data instanceof Array && u.default.getInstance().loadConfig(t.data.data), 
                    GA.Info.underCheck && l.GC.isDebug ? u.default.getInstance().loadData({}) : u.default.getInstance().loadData(e), 
                    d.GD.isNew ? h.default.getInstance().fsStartTime = Date.now() + 1e3 * l.GC.fsNewStartTime : h.default.getInstance().fsStartTime = Date.now() + 1e3 * l.GC.fsOldStartTime, 
                    u.default.getInstance().loadRes(function() {
                        0 < n.startTime && p.default.getInstance().sentLog("loadTime", Date.now() - n.startTime), 
                        GA.isByteDance() && [ 6, 15, 17, 18 ].forEach(function(t) {
                            l.GC.personExpectList.includes(t) || l.GC.personExpectList.push(t), l.GC.personUnderCheckExpectList.includes(t) || l.GC.personUnderCheckExpectList.push(t);
                        }), GA.Info.underCheck ? (l.GC.isDebug && (d.GD.load(l.GC.getInfo(l.GC.DEBUGDATA, {})), 
                        l.GC.load(l.GC.getInfo(l.GC.DEBUGCONFIG, {}))), c.G.personModelList = c.G.personModelList.filter(function(t) {
                            return !l.GC.personUnderCheckExpectList.includes(t.id);
                        }), c.G.eggPersonModelList = c.G.eggPersonModelList.filter(function(t) {
                            return !l.GC.eggPersonUnderCheckExpectList.includes(t.id);
                        })) : (c.G.personModelList = c.G.personModelList.filter(function(t) {
                            return !l.GC.personExpectList.includes(t.id);
                        }), c.G.eggPersonModelList = c.G.eggPersonModelList.filter(function(t) {
                            return !l.GC.eggPersonExpectList.includes(t.id);
                        })), -1 < d.GD.personIdx ? 0 == c.G.personModelList.filter(function(t) {
                            return t.id == d.GD.personIdx;
                        }).length && (d.GD.personIdx = 0) : 0 == c.G.eggPersonModelList.filter(function(t) {
                            return t.id == 1 - d.GD.personIdx;
                        }).length && (d.GD.personIdx = 0), cc.director.loadScene(n.main_scence);
                    }), p.default.getInstance().getCity({
                        success: function(t) {
                            console.log("getCity", t);
                            t = t.data.data.regionName;
                            "北京" != t && "上海" != t && "广州" != t && "深圳" != t || (c.G.sensitiveCity = !0);
                        }
                    });
                }
            });
        });
    }, t.prototype.progressCallback = function(t, e, n, o) {
        this.load_progress && o < this.load_progress.length && (this.load_progress[o] = t / e, 
        this.refreshProgress());
    }, t.prototype.refreshProgress = function() {
        var e = this, n = 0;
        this.load_progress && this.load_progress.forEach(function(t) {
            isNaN(t) || (n += t / e.load_total);
        }), this.progress_sprite.fillRange = n, this.progress_label.string = "加载 " + (100 * this.progress_sprite.fillRange).toFixed(0) + "%";
    }, t.prototype.finishProgress = function(t) {
        this.load_progress && t < this.load_progress.length && (this.load_progress[t] = 1, 
        this.refreshProgress());
    }, t.prototype.update = function(t) {
        this.load_progress && 1 < this.load_progress.length && this.load_progress[1] < 1 && (this.load_progress[1] += t, 
        this.refreshProgress());
    }, a([ m(cc.Label) ], t.prototype, "progress_label", void 0), a([ m(cc.Sprite) ], t.prototype, "progress_sprite", void 0), 
    a([ m(cc.Node) ], t.prototype, "box", void 0), a([ g ], t);
}(cc.Component);

n.default = y;